from flask import Blueprint
from flask_restful import Api
from utils.constants import BASE_URL_PRIFIX

# 1.创建蓝图对象
article_bp = Blueprint('article', __name__, url_prefix=BASE_URL_PRIFIX)

# 2.创建Api对象
article_api = Api(article_bp)

# 设置json包装格式
from utils.output import output_json

# 使用组件对象设置json转换函数
article_api.representation('application/json')(output_json)

# 配置URL
from .channel import AllChannelResource
from .articles import ArticleListResource, ArticleDetailResource
from .following import  FollowUserResource
from .comment import CommentsResource
# 添加获取所有频道类视图
article_api.add_resource(AllChannelResource, '/channels')
# 添加首页文章列表类视图
article_api.add_resource(ArticleListResource, '/articles')
# 添加获取文章详情页类视图
article_api.add_resource(ArticleDetailResource, '/articles/<int:article_id>')
# 添加关注用户类视图
article_api.add_resource(FollowUserResource, '/user/followings')
# 添加发布评论类视图
article_api.add_resource(CommentsResource, '/comments')
